{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "b244f3de",
   "metadata": {},
   "source": [
    "# 上周回顾\n",
    "## 1.字典的三种创建方式\n",
    "## 2.字典的性质\n",
    "> 1.无序的\n",
    "> 2.key 具有唯一性\n",
    "> 3. key 不可变\n",
    "\n",
    "# 本周学习内容\n",
    "\n",
    "# 1.字典的循环遍历\n",
    "\n",
    "# 2.字典的一般方法\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "be363447",
   "metadata": {},
   "outputs": [],
   "source": [
    "info = {\n",
    "    \"stu1801\":\"ZiQi\",\n",
    "    \"stu1802\":\"XiaoFeng\",\n",
    "    \"stu1803\":\"LiuYu\"\n",
    "}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9682fc81",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu1801': 'ZiQi', 'stu1802': 'XiaoFeng', 'stu1803': 'LiuYu'}\n"
     ]
    }
   ],
   "source": [
    "print(info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "3c9ac8c5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu1801\n",
      "stu1802\n",
      "stu1803\n"
     ]
    }
   ],
   "source": [
    "# A-1\n",
    "# i 指内容/y元素（item)\n",
    "for i in info:\n",
    "    print(i)\n",
    "    # i只是key的值，并没有真正意义上获取到字典的完整信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e3e02cf1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu1801 ZiQi\n",
      "stu1802 XiaoFeng\n",
      "stu1803 LiuYu\n"
     ]
    }
   ],
   "source": [
    "# A-2\n",
    "#  字典的循环 如何循环key:value 作为items输出\n",
    "for k,v in info.items():\n",
    "    print(k,v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "5c4b0413",
   "metadata": {},
   "outputs": [],
   "source": [
    "#  实践1：学号的k 去掉stu 然后输出新的字典\n",
    "new_info = {}\n",
    "\n",
    "for k,v in info.items():\n",
    "    # 字典的新增\n",
    "    new_info[k[3:]] = v.upper()\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "003895b7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'1801': 'ZIQI', '1802': 'XIAOFENG', '1803': 'LIUYU'}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cdbb3ef2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8a7dbeb0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c7f57ed0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "20755b2f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
